//============================================================================
// Name        : 2_1_2_Linux.cpp
// Author      : Eric Chen
// Version     :
// Copyright   : Your copyright notice
// Description : Insertion sort non increase;Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int A[]={31,41,59,26,41};

void printArray(int array[],int size)
{
	if(size>0)
	{
		for(int i=0;i<size;i++)
			cout<<array[i]<<",";
		cout<<endl;
	}
	else
	{
		cout<<"Damn,give me a correct array please"<<endl;
	}



}
int main() {

	int size=(sizeof(A)/sizeof(int));
	cout<<"Array before sort:"<<endl;
	printArray(A,size);
	for(int j=1;j<size;j++)
	{
		int key=A[j];
		int i=j-1;
		for(;(i>=0&&A[i]<key);i--)
		{
			A[i+1]=A[i];
		}
		A[i+1]=key;

	}
	cout<<"Array after sort:"<<endl;
	printArray(A,size);
	return 0;
}
